<!DOCTYPE html>
<html lang="zh">
<head>
	#@header()
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		#if(permission != null && permission.get('select')!= null )
		<div class="col-sm-12 search-collapse" >
			<form id="role-form">
				<div class="select-list">
					<ul>
						<li>
							标题/二级标题：<input type="text" name="stitle"/>
						</li>

						<li>
							联系人：<input type="text" name="slinkman"/>
						</li>

						<li>
							邮箱：<input type="text" name="semail"/>
						</li>

						<li>
							分类：
							<select name="type">
								<option value="0">--全部--</option>
								<option value="1">光学世界</option>
								<option value="2">精细化工</option>
								<option value="3">新能源材料</option>
								<option value="4">新兴半导体</option>
								<option value="5">LCP系列</option>
							</select>
						</li>

						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>
		#end

		<div class="btn-group-sm" id="toolbar" role="group">
			#if(permission != null && permission.get('select')!= null )
			<a class="btn btn-success" onclick="$.operate.addFull()">
				<i class="fa fa-plus"></i> 新增
			</a>
			#end

		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>


#@footer()

<script type="text/javascript">

    var editFlag = true;
    var removeFlag = true;
    $(function() {
        var options = {
            url: "#(prj)/admin/product/paginate",
            createUrl: "#(prj)/admin/product/add",
            updateUrl: "#(prj)/admin/product/edit/{id}",
            removeUrl: "#(prj)/admin/product/delete/{id}",
            exportUrl: "#(prj)/admin/product/export",
            sortName: "sort",
            modalName: "产品信息",
            columns: [
                {
                    field: 'cover_img',
                    title: '封面图',
                    formatter: function (value, row, index) {
						value = '#(prj)'+row.cover_img;
                        return lcbase.imgView(value);
                        //return $.table.imageView(value);
                    }
                },
                {
                    field: 'title',
                    title: '标题'
                },
                {
                    field: 'subtitle',
                    title: '二级标题',
                    formatter: function (value, row, index) {
                        if(value.length > 20){
                            return '<p title="'+value+'">'+value.substring(0,20)+'...'+'<p>'
						}else{
                            return value;
						}
                    }
                },
				{
				    field:'type',
					title:'分类',
					formatter: function (value,row,index) {
						if(value == 1){
						    return "光学世界";
						}else if(value == 2){
						   return "精细化工";
						}else if(value == 3){
						    return "新能源材料";
						}else if(value == 4){
						    return "新兴半导体";

						}else if(value == 5){
						    return "LCP系列";
						}else {
						    return "其他";
						}
                    }
				},
/*                {
                    field: 'linkman',
                    title: '联系人',
                },*/
                {
                    field: 'email',
                    title: '邮箱',
                },
                {
                    field: 'sort',
                    title: '排序',
                    sortable: true,
                },
                {
                    field: 'create_time',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'update_time',
                    title: '创建时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (row.roleId != 1) {
                            var actions = []
                        #if(permission != null && permission.get('update')!= null )
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ')
						#end
                        #if(permission != null && permission.get('delete')!= null )
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ')
						#end

                            return actions.join('');
                        } else {
                            return "";
                        }
                    }
                }]
        };
        $.table.init(options);
    });


    /* 后台管理状态显示 */
    function statusTools(row) {
        if (row.status == 1) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
        }
    }

    /* 后台管理-停用 */
    function disable(id) {
        $.modal.confirm("确认<span style='color: red'>锁定</span>该用户吗？", function() {
            $.post("#(prj)/admin/product/onLock",{"id":id},function (res) {
                if(res.state == 'ok'){
                    $.modal.msgSuccess(res.msg)
                    $.table.refresh();
                }
            })
        })
    }

    /* 后台管理启用 */
    function enable(id) {
        $.modal.confirm("确认<span style='color: green'>解锁</span>该用户吗？", function() {
            $.post("#(prj)/admin/product/offLock",{"id":id},function (res) {
                if(res.state == 'ok'){
                    $.modal.msgSuccess(res.msg)
                    $.table.refresh();
                }
            })
        })
    }
</script>
</body>
</html>